import 'package:amap/src/pick/pick_location_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'src/amap/model/common.dart';

export 'src/MapView.dart';
export 'src/MapViewController.dart';
export 'src/MessageReply.dart';
export 'src/amap/map_constants.dart';
export 'src/amap/map_creation_params.dart';
export 'src/amap/model/circle_options.dart';
export 'src/amap/model/common.dart';
export 'src/amap/model/marker_options.dart';
export 'src/amap/model/polyline_options.dart';
export 'src/amap/my_location_style.dart';
export 'src/amap/ui_settings.dart';
export 'src/bean/MapClickedEvent.dart';

abstract class AMap {
  static const mapViewType = "com.jameskarl/mapView";
  static const channelName = "com.jameskarl/map";

  static const bool showDebugMessage = false;

  static const _platform = const MethodChannel(channelName);

  static Future<double> distance(LatLng from, LatLng to) async {
    if (from == null || to == null || !from.valid || !to.valid) return 0;
    return _platform.invokeMethod("distance", {"from": from, "to": to});
  }

  static Future<MapLocation> pickLocation(BuildContext context,
      {LatLng initialTarget}) {
    return Navigator.of(context).push(
      MaterialPageRoute(
        builder: (BuildContext context) {
          return PickLocationPage();
        },
      ),
    );
  }
}
